﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Small.Util.Reflection;

namespace Small.Util.Common
{
   public  class AttachHtmlAttribute
    {

       /// <summary>
       /// 根据属性设置Html标签的属性
       /// </summary>
       /// <param name="htmlAttribute">属性值[attribute= name ]</param>
       /// <returns></returns>
       public static string GetHtmlAttributes(object htmlAttribute)
       {
           var htmlAttributes = AnonymousProperties.GetAnonymousInfomation(htmlAttribute);
           StringBuilder builder = new StringBuilder();
           if (htmlAttributes != null)
           {
               foreach (var item1 in htmlAttributes)
               {

                   builder.Append("  " + item1.Name + "=\"" + item1.Value + "\"");
               }
           }

           return builder.ToString();

       }
    }
}
